package com.gview.example.common.viewStatic;


import com.gonsin.gview.annotations.GView;
import com.gonsin.gview.annotations.board.GBoard;
import com.gonsin.gview.annotations.board.GButton;
import com.gonsin.gview.annotations.board.form.GTextInput;
import com.gonsin.gview.annotations.board.table.*;
import com.gonsin.gview.annotations.data.GTableData;
import com.gonsin.gview.annotations.enums.ButtonAction;
import com.gonsin.gview.annotations.enums.ColumnType;

@GView(
        viewName = "BookView1",
        title = "图书管理",
        boards = {
                @GBoard(table = @GTable(
                        tableData = @GTableData(fromDataSource = "searchBook", keyName = "bookKey"),
                        header = @GHeader(
                                buttons = {
                                        @GButton(name = "新添加", action = ButtonAction.VIEW_BY_DIALOG, view = "AddBook"),
                                        @GButton(name = "删除", action = ButtonAction.BATCH, actionName = "batchDeleteBook")
                                },
                                searchBar = @GSearchBar(filters = {
                                        @GSearchFilter(textInput = @GTextInput(keyName = "bookNickname", name = "查找", placeholder = "输入图书名字"))
                                })
                        ),
                        columns = {
                                @GColumn(name = "名字", keyName = "bookName"),
                                @GColumn(name = "作者", keyName = "author"),
                                @GColumn(name = "价格", value = "{{item.price}} ￥"),
                                @GColumn(name = "操作", columnType = ColumnType.BUTTONS,
                                        buttons = {
                                                @GButton(name = "编辑", action = ButtonAction.VIEW_BY_DIALOG, view = "UpdateBook",
                                                        props = @GProp(keyName = "bookKey", valueName = "{{item.bookKey}}")),
                                                @GButton(name = "删除",
                                                        action = ButtonAction.CONFIRM,
                                                        actionName = "deleteBook",
                                                        confirmMessage = "是否确认删除该设备？",
                                                        props = {@GProp(keyName = "bookKey", valueName = "{{item.bookKey}}")}
                                                )
                                        })
                        }
                ))
        }
)
public class BookView {
}
